#include "syscall.h"


void print(void* c)
{
    PutChar((char)c);
    PutChar('\n');
	UserThreadExit();   
}
void printb()
{
    int j=0;
    while (j<30){
    PutChar('b');
    j++;}
   UserThreadExit(); 
}
void printa()
{
    int i=0;
    while (i<30){
    PutChar('a');
    i++;}
   UserThreadExit(); 
}
void mprint(void *c){
int i=0;
char a= (char)(((int)c)/128);
int n=((int)c)-((int)a*128);
PutInt(n);

while(i<n)  {
PutString("Thread '");	
PutChar(a);
PutString("' > ");
PutInt(i+1);
PutString("\n");
i=i+1;
}
}
void * concat(int i,char c){
 int a1 = (int)c;
    a1=a1*128+i;    
	return (void*)a1;
	};
int main()
{
    int i=0;
	
    int tid[5];
        PutChar('>');
	//UserThreadCreate(mprint, concat(20,'W'));
	//UserThreadCreate(mprint, concat(30,'S'));
	tid[0] = UserThreadCreate(print, (void*)'a');
	UserThreadJoin(tid[0]);
	tid[1] = UserThreadCreate(print, (int*)'b');
	UserThreadJoin(tid[1]);
	tid[2] = UserThreadCreate(print, (int*)'c');
	UserThreadJoin(tid[2]);
	tid[3] = UserThreadCreate(print, (int*)'d');
	UserThreadJoin(tid[3]);
	tid[4] = UserThreadCreate(print, (int*)'e');
	UserThreadJoin(tid[4]);
	//while (i++<100000);
	PutChar('\n');
	
  return 0;
}
